package com.kaifamiao.www.ioDemo.do0921;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class Demo01 {

    public static void main(String[] args) {

        /**
         * InputStream 类是所有字节输入流的父类
          */
        try (FileInputStream fis = new FileInputStream("E:\\kaifamiao\\workspace\\idea--space\\io\\test.txt");
             BufferedInputStream bis = new BufferedInputStream(fis);
        ){
            System.out.println("可读取的字节数:"+fis.available());
            System.out.println("文件内容为:" );
            byte[] bytes = new byte[fis.available()];
            String s = "";
            while ((bis.read(bytes))!= -1){
                s = new String(bytes);
            }
            System.out.println(s);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
